package com.sitia.jd.controller;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import com.sitia.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sitia.common.annotation.Log;
import com.sitia.common.core.controller.BaseController;
import com.sitia.common.core.domain.AjaxResult;
import com.sitia.common.enums.BusinessType;
import com.sitia.jd.domain.CashOutOrder;
import com.sitia.jd.service.ICashOutOrderService;
import com.sitia.common.utils.poi.ExcelUtil;
import com.sitia.common.core.page.TableDataInfo;

/**
 * 提现订单Controller
 * 
 * @author sitia
 * @date 2025-06-23
 */
@RestController
@RequestMapping("/cashOut/order")
public class CashOutOrderController extends BaseController
{
    @Resource
    private ICashOutOrderService cashOutOrderService;

    /**
     * 查询提现订单列表
     */
    @GetMapping("/list")
    public TableDataInfo list(CashOutOrder cashOutOrder)
    {
        startPage();
        List<CashOutOrder> list = cashOutOrderService.selectCashOutOrderList(cashOutOrder);
        return getDataTable(list);
    }

    /**
     * 查询提现订单列表
     */
    @GetMapping("/pageList")
    public TableDataInfo pageList(CashOutOrder cashOutOrder)
    {
        startPage();
        cashOutOrder.setOwnerId(SecurityUtils.getUsername());
        List<CashOutOrder> list = cashOutOrderService.selectCashOutOrderPageList(cashOutOrder);
        return getDataTable(list);
    }

    /**
     * 导出提现订单列表
     */
    @Log(title = "提现订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CashOutOrder cashOutOrder)
    {
        List<CashOutOrder> list = cashOutOrderService.selectCashOutOrderList(cashOutOrder);
        ExcelUtil<CashOutOrder> util = new ExcelUtil<CashOutOrder>(CashOutOrder.class);
        util.exportExcel(response, list, "提现订单数据");
    }

    /**
     * 获取提现订单详细信息
     */
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") String orderId)
    {
        return success(cashOutOrderService.selectCashOutOrderByOrderId(orderId));
    }

    /**
     * 新增提现订单
     */
    @PostMapping
    public AjaxResult add(@RequestBody CashOutOrder cashOutOrder)
    {
        return toAjax(cashOutOrderService.addCashOutOrder(cashOutOrder));
    }

    /**
     * 修改提现订单
     */
    @PutMapping
    public AjaxResult edit(@RequestBody CashOutOrder cashOutOrder)
    {
        return toAjax(cashOutOrderService.updateCashOutOrder(cashOutOrder));
    }

    /**
     * 删除提现订单
     */
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable String[] orderIds)
    {
        return toAjax(cashOutOrderService.deleteCashOutOrderByOrderIds(orderIds));
    }
}
